package com.zzj.utils;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public  class CodeGeneratorService {
    @Value("${spring.datasource.url}")
    private String url;
    @Value("${spring.datasource.username}")
    private String username;
    @Value("${spring.datasource.password}")
    private String password;

    public void codeGenerator() {
        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> {
                    builder.author("zzj")
                            .commentDate("yyyy-MM-dd")  //默认值: yyyy-MM-dd
                            .outputDir("G:\\项目\\0210\\整理\\picc-api\\picc-server\\src\\main\\java")  //指定输出目录
                            .dateType(DateType.ONLY_DATE);  // 日期类型设置为仅日期，忽略时间部分
                })
                .packageConfig(builder -> {
                    builder.parent("com.zzj");
                })
                .strategyConfig(builder -> {
                    builder
                            .addTablePrefix("picc")
                            .addInclude("picc_maintain")
                            .addInclude("picc_extubation")
                            .addInclude("picc_catheter")
                            .controllerBuilder()
                            .enableRestStyle();
                })
                .execute();
    }

}
